<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .contianer {
            margin: 50px;
        }

        .contianer li {
            margin-bottom: 10px;
        }

        .demo {
            width: 50px;
            height: 50px;
            background: rgb(147, 248, 226);
            position: relative;
            overflow: hidden;
        }

        .demo2.active {
            animation: active 0.5s forwards ease-in-out;
        }

        @keyframes active {
            from {
                opacity: 0;
                transform: rotate(180deg);
            }

            to {
                opacity: 1;
                transform: rotate(0deg);
            }
        }

        .demo2.leave {
            animation: leave 0.5s forwards ease-in-out;
        }

        @keyframes leave {
            from {
                opacity: 1;
                transform: rotate(0deg);
            }

            to {
                opacity: 0;
                transform: rotate(180deg);
            }
        }

        .demo2 {
            width: 50px;
            height: 50px;
            position: absolute;
            left: 0;
            top: 0;
            background: rgb(3, 253, 199);
            transform-origin: left center;
            transform: rotate(180deg);
            opacity: 0;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <ul class="contianer">
        <li class="demo">1
            <div class="demo2">2</div>
        </li>
    </ul>
</body>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
    $(".demo").mouseenter(function(){
        $(this).children().addClass("active")
    })
</script>

</html>